import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { FriendService } from './friend.service';
import { AddFriendDto, UpdateFriendDto,addGroupDto } from './dto/friend.dto';


@Controller('friend')
export class FriendController {
  constructor(private readonly friendService: FriendService) {}

  @Post('add')
  create(@Body() addFriendDto: AddFriendDto) {
    return this.friendService.create(addFriendDto);
  }

  @Post('group')
  group(@Body() addGroupDto: addGroupDto) {
    return this.friendService.createGroup(addGroupDto);
  }

  @Get('all')
  findAll(@Query() query) {
    return this.friendService.findAll(query);
  }
  @Get('message')
  message(@Query() query) {
    console.log('query', query);
    return this.friendService.getMessage(query);
  }
  // getMessage

  @Get('/filter')
  findOne(@Query('code') code: string) {
    return this.friendService.findOne(code);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateFriendDto: UpdateFriendDto) {
    return this.friendService.update(+id, updateFriendDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.friendService.remove(+id);
  }
}
